import * as mobx from 'mobx';
import { ListStore } from '../listStore';
import { WeaTools , WeaLocaleProvider} from 'ecCom';
import { WeaForm } from 'comsMobx';
import * as API_CUSTOMREPORTADD from '../../apis/customReportAdd';
import { message } from 'antd';
const { getLabel , formatMultiLang } = WeaLocaleProvider;

const observable = mobx.observable;
const action = mobx.action;

export class WFCusReportAddStore extends ListStore{

    
    //参数
    @observable customReportAddModalShow = false;
    //基本信息
    @observable reportBaseinfo = {
        reportName : '',//报表名称
        reportList : [],//表单
        reportRoute : [],//报表路径,
        workflowToFormid:'',//路径带出的formid
        workflowToIsbill:'',//路径带出的isbill
    }
    formReplaceDatas =[];
    wfReplaceDatas=[];
    @observable baseInfoItemList = [];//后续增加的基础信息设置itemList
    //saveData
    @observable baseInfoFlag = 0;//是否保存
    @observable groupFlag = 0;//分组是否保存
    @observable sortFlag = 0;//排序是否保存
    @observable proJectFlag = 0;//排序是否保存
    //统计分组
    @observable groupSelectedKeys = [];
    groupOptions = [];
    formulaInfo = [];
    @observable  groupData=[];
    //统计项目
    @observable proJectDataSource = []
    @observable proJectRowKeys = [];
    @observable proJectAddModalShow = false;
    @observable proJectModalParams = {};
    @observable formulaName = "";
    @observable currentStep = 0;//-------------------------
    @observable proJectTitle = getLabel(386303,"新建统计项目");
    deleteKeys = [];//删除公式的id
    lockState = 1;
    @observable formulaForm = new WeaForm();
    formulaCondition = [{
        title:'',
        defaultShow:true,
        items:[{   
            colSpan : 2,
            conditionType:"INPUT",
            domkey:["formulaName"],
            fieldcol:18,
            isQuickSearch:false,
            label:getLabel(386255,"公式名称"),
            labelcol:6,
            rules:"required|string",
            value:"",
            viewAttr:3,
            className:"count_project_name"
        }]
    }]
    //数据排序
    @observable  sortOptions = [];
    @observable sortData = [];
    @observable sortSelectedKeys = [];
    sortSelectedDatas = [];
    tempKeys=[];
    tempSortInfo = [];//保存临时排序信息
    //完成

    //初始化表单信息
    @observable formBrowser = {};
    wfBrowser = {};
    @observable formBrowserId = "";
    @observable formBrowserIsbill = 1;
    @observable wfBrowserShow = false;
    @observable baseBrowserViewAttr = 3;//保存后为只读
    reportid;
    @observable modalTitle=getLabel(386304,"新建分析报表");
    editPortFlag = false;
    firstChoose = 1;//是否是先选择form
    //

    constructor() {
        super();
        this.title = getLabel(386304,"新建分析报表");
        
        this.initDatas = this.initDatas.bind(this);
        this.initDatasSteps = this.initDatasSteps.bind(this);
        this.eachStepSave = this.eachStepSave.bind(this);
        this.setCurrentStep = this.setCurrentStep.bind(this);
        this.clearStatus = this.clearStatus.bind(this);

        this.setBaseInfo = this.setBaseInfo.bind(this);
        this.setGroupDatas = this.setGroupDatas.bind(this);
        this.setSortDatas = this.setSortDatas.bind(this);
        this.setDataSource = this.setDataSource.bind(this);

        this.setProJectRowKeys = this.setProJectRowKeys.bind(this);
        this.proJectRowClick = this.proJectRowClick.bind(this);
        this.setProJectAddModalShow = this.setProJectAddModalShow.bind(this);
        this.saveFormula = this.saveFormula.bind(this);
        this.setFormulaName = this.setFormulaName.bind(this);

        this.setSortSelectedDatasOrder = this.setSortSelectedDatasOrder.bind(this);
        this.setCusReportAddModalShow = this.setCusReportAddModalShow.bind(this);
        this.baseInfoFormChange = this.baseInfoFormChange.bind(this);
        this.saveformulaListIndex  = this.saveformulaListIndex.bind(this);
        this.workflowPathOnchange  = this.workflowPathOnchange.bind(this);

    }

    @action
    initDatas(reportid){
        /** 
         * step=1,2
         * formid
         * isbill
         * 初始化基本信息的表单和路径输入框
        */
		if(this.formulaCondition && this.formulaCondition[0]&&this.formulaCondition[0].items&&this.formulaCondition[0].items[0])
        this.formulaCondition[0].items[0].label=getLabel(386255,"公式名称");
       this.formulaForm.initFormFields(this.formulaCondition);

       reportid && API_CUSTOMREPORTADD.getBrowserInfo({reportid : reportid}).then((data)=>{
            this.wfBrowser = data.wfBrowser;
            this.formBrowser = data.formBrowser;
            this.baseInfoItemList = data.itemList;
        })
    }
    initDatasSteps(params={}){
        if(params.step == 2){
            let tempFormId = '',tempBill='';
            if(this.reportBaseinfo.workflowToFormid!=''){
                tempFormId = this.reportBaseinfo.workflowToFormid;
                tempBill = this.reportBaseinfo.workflowToIsbill;
            }else{
                tempFormId = this.formBrowserId;
                tempBill = this.formBrowserIsbill;
            }
            params={
                formid : tempFormId,
                isbill : tempBill
            }
            API_CUSTOMREPORTADD.getFormFields(params).then((data)=>{
                this.groupOptions = data.tableOptions;
                this.groupData = data.fields.filter((field)=> {return field.groupby});
            });
        }
        if(params.step == 3){
            

            API_CUSTOMREPORTADD.getFunctionList().then((data)=>{
                this.formulaInfo = data.formulaInfo;
            });
        }
        if(params.step == 4){
            API_CUSTOMREPORTADD.getReportOrderByFields({reportid:this.reportid}).then((data)=>{
                const { sortfields = [],sorttableOptions=[]}=data;

               let datas = this.sortData;
               let sortArr =[];
               let  sortInfo = this.tempSortInfo,sortKeys=[];
               sortInfo.length>0?sortInfo.map(v=>{
                    sortKeys.push(v.id);
                    sortfields.map(c=>{
                        if(c.id==v.id){
                            c['sortNumber'] = v.sortby;
                            sortArr.push(c);
                        }else if (!c['sortNumber']){
                            c['sortNumber'] = '1';
                        }
                    });
                }):sortfields.map(c=>{
                        c['sortNumber'] = '1';
                });
                this.sortSelectedDatas = sortArr;
                this.sortOptions = sorttableOptions;

                this.sortData = sortfields;
                this.sortSelectedKeys = sortKeys;
            });
        }
        
        //保存
    }
    //每个步骤的保存 数据
    eachStepSave(params={}){
        const{reportid,editPortFlag,baseInfoFlag,groupFlag,sortFlag,proJectFlag}=this;
        let queryParams = {};
        if(reportid&&reportid!=""&&editPortFlag&&baseInfoFlag&&groupFlag&&sortFlag&&proJectFlag){
            message.destroy();
            message.success(getLabel(83551,'保存成功！'));
        }else{
            if(params.step==1){
                let wfIds = "";
                params.reportRoute.length>0&&params.reportRoute.map((v,i)=>{
                    wfIds = wfIds + v.id+",";
                });
                wfIds = wfIds.substring(0,wfIds.length-1);
                //先去workflow带出的表单id再去自己选择的formid
                let tempFormId = '',tempBill='';
                if(this.reportBaseinfo.workflowToFormid!=''){
                    tempFormId = this.reportBaseinfo.workflowToFormid;
                    tempBill = this.reportBaseinfo.workflowToIsbill;
                }else{
                    tempFormId = this.formBrowserId;
                    tempBill = this.formBrowserIsbill;
                }
                queryParams = {
                    secLevel : params.secLevel,
                    reportName:params.reportName,
                    formid : tempFormId,
                    workflowid:wfIds,
                    isbill:tempBill
                }
                this.reportid?queryParams.reportid = this.reportid:"";
                this.loading = true;
                API_CUSTOMREPORTADD.saveReportBase(queryParams).then((data)=>{
                    const {formReplaceDatas=this.reportBaseinfo.reportList , wfReplaceDatas=[],reportid=""} = data;//保存后最好给出保存成功数据
                    
                    message.success(getLabel(83551,'保存成功！'));
                    if(reportid!=""){
                        this.reportid = reportid;
                    }
                    
                    this.title = getLabel(386305,"编辑分析报表")+'：'+formatMultiLang(params.reportName);
                   
                    let wf_replace = [];
                    let arr = [];
                    if(wfReplaceDatas.length>0){
                        if(wfReplaceDatas[0].id==""){
                            arr = this.reportBaseinfo.reportRoute;
                        }else{
                            arr=wfReplaceDatas;
                        }
                    }else{
                        arr = this.reportBaseinfo.reportRoute;
                    }
                    
                    if(wfIds==""){
                        wf_replace=[];
                    }else{
                        wf_replace=arr;
                    }
                    
                    this.reportBaseinfo =  {...this.reportBaseinfo,reportList:formReplaceDatas,reportRoute:wf_replace};
                    //condition form
                    API_CUSTOMREPORTADD.getBrowserInfo({reportid : this.reportid}).then((data)=>{
                        this.baseInfoItemList = data.itemList;

                        this.setNowFormInfo(false,formReplaceDatas,wf_replace,params.reportName,
                            {wf:{formid:this.formBrowserId,isbill:this.formBrowserIsbill},form:{workflowid:wfIds}},[3,2,1]);
                  
                        this.baseInfoFlag = 1;
                        this.baseBrowserViewAttr = 1;
                       
                        if(params.changeCurFlag){
                            this.currentStep = params.changeCurIndex;
                        }
                        this.loading = false;
                    })

                });
            }
            //step2
            if(params.step==2){
                params.groupSelectedKeys&&params.groupSelectedKeys.map((v,i)=>{
                    this.groupData.length>0&&this.groupData.map((c,k)=>{
                        if(v==c.id){
                            queryParams['fieldid_'+i] = v; 
                            queryParams['tablename_'+i] = c.tabletype;
                            queryParams['viewtype_'+i] = c.viewtype?c.viewtype:'-1';
                        }
                    })
                })
                queryParams.reportid = this.reportid;
                queryParams.fieldCount = params.groupSelectedKeys&&params.groupSelectedKeys.length;
                API_CUSTOMREPORTADD.saveReportField(queryParams).then((data)=>{
                    
                    this.groupFlag = 1;
                    if(params.changeCurFlag){
                        this.currentStep = params.changeCurIndex;
                    }
                    message.success(getLabel(83551,'保存成功！'));

                    let sorts = [];
                    this.sortSelectedKeys.map(v=>{
                        if(isNaN(v)){
                            sorts.push(v);
                        }else{
                            params.groupSelectedKeys.map(c=>{
                                if(v==c){
                                    sorts.push(v);
                                }
                            })
                        }
                    });
                    this.sortSelectedKeys = sorts;
                });
            }
            //step3
            if(params.step==3){
                this.proJectDataSource.length>0&&this.proJectDataSource.map((v,i)=>{
                    queryParams['id_'+i] = v.id ||""; 
                    queryParams['projectname_'+i] = v.name.props.children; 
                    queryParams['formula_'+i] = v.formula.props.children; 
                    queryParams['formulaDesc_'+i] = v.formulaDesc.props.children; 
                    queryParams['showorder_'+i] = i;
                })
                queryParams.reportid = this.reportid;
                queryParams.formulaCount = this.proJectDataSource.length;
                if(this.deleteKeys.length>0){
                    let ids = "";
                    this.deleteKeys.map(v=>{
                        ids = ids + v +",";
                    }) 
                    ids = ids.substring(0,ids.length-1);
                    queryParams.deleteIds = ids;
                }
                API_CUSTOMREPORTADD.saveReportFormula(queryParams).then((data)=>{
                    if(params.changeCurFlag){
                        this.currentStep = params.changeCurIndex;
                    }
                    if(data.success==false) message.error("保存失败！");
                    else{
                        let formulaTempData = [];
                        data.success && data.formulaInfo.map((v,i)=>{
                            formulaTempData.push({
                                id:v.id,
                                key : v.id,
                                title:v.projectname,
                                name:<a>{v.projectname}</a>,
                                lanName:<a>{formatMultiLang(v.projectname)}</a>,
                                formula:<a>{v.formula}</a>,
                                formulaDesc:<a>{v.formulaDesc}</a>
                            })
                        })
                        this.proJectDataSource = formulaTempData;
                        this.proJectFlag = 1;
                        message.success(getLabel(83551,'保存成功！'));
                    }
                });
            }
            if(params.step==4){
                let selectedKeys = [];
                this.sortSelectedDatas.map((v,i)=>{
                    queryParams['fieldid_'+i] = v.id;
                    queryParams['sortby_'+i] = Number(v.sortNumber || '1');
                    selectedKeys.push(v.id);
                });
                this.sortSelectedKeys = selectedKeys;
                queryParams.reportid = this.reportid;
                queryParams.fieldCount = this.sortSelectedDatas&&this.sortSelectedDatas.length;
                API_CUSTOMREPORTADD.saveReportSortField(queryParams).then((data)=>{
                    const { sortInfo=[] } = data;
                    this.sortFlag = 1;
                    
                    if(params.changeCurFlag){
                        this.currentStep = params.changeCurIndex;
                    }
                    if(data.success){
                        this.tempSortInfo = sortInfo;
                        message.success(getLabel(83551,'保存成功！'));
                    }
                });
            }
        }
    }

    setNowFormInfo(needInitForm=false,formReplaceDatas=[],wf_replace=[],defaultReportName='',dataParams={wf:{},form:{}},viewAttr=[3,2,2]){
        let conditionsss = [{
            title:'',
            defaultShow:true,
            items:[
                {   
                    colSpan : 2,
                    conditionType:"INPUT",
                    domkey:["reportname"],
                    fieldcol:18,
                    isQuickSearch:false,
                    label:getLabel(15517,"报表名称"),
                    labelcol:6,
                    rules:"required|string|stringLength:100",
                    value:defaultReportName,
                    viewAttr:viewAttr[0],
                },
                {
                    browserConditionParam:{
                        completeParams:{},
                        conditionDataParams:{},
                        dataParams:dataParams.wf,
                        destDataParams:{},
                        hasAddBtn:false,
                        hasAdvanceSerach:true,
                        hasBorder:false,
                        icon:"icon-coms-workflow",
                        iconBgcolor:"#0079DE",
                        idSeparator:",",
                        isAutoComplete:1,
                        isDetail:0,
                        isMultCheckbox:false,
                        isSingle:true,
                        pageSize:10,
                        quickSearchName:"",
                        replaceDatas:wf_replace,
                        title:getLabel(26361,"工作流"),
                        type:"-99991",
                        viewAttr:2,
                    },
                    colSpan:2,
                    conditionType:"BROWSER",
                    domkey:["path"],
                    fieldcol:18,
                    isQuickSearch:false,
                    label:getLabel(381969,"相关路径"),
                    labelcol:6,
                    viewAttr:2,
                },{
                    browserConditionParam:{
                        completeParams:{},
                        conditionDataParams:{},
                        dataParams:dataParams.form,
                        destDataParams:{},
                        hasAddBtn:false,
                        hasAdvanceSerach:true,
                        hasBorder:false,
                        icon:"icon-coms-workflow",
                        iconBgcolor:"#0079DE",
                        idSeparator:",",
                        isAutoComplete:1,
                        isDetail:0,
                        isMultCheckbox:false,
                        isSingle:true,
                        pageSize:10,
                        quickSearchName:"",
                        replaceDatas:formReplaceDatas,
                        title:getLabel(15451,"表单名称"),
                        type:"wfFormBrowser",
                        viewAttr:viewAttr[2],
                    },
                    colSpan:2,
                    conditionType:"BROWSER",
                    domkey:["form"],
                    fieldcol:18,
                    isQuickSearch:false,
                    label:getLabel(15600,"对应表单"),
                    labelcol:6,
                    viewAttr:viewAttr[2],
                }
            ]
        }];
        
        this.baseInfoItemList.map(item => {
            conditionsss[0].items.push(item);
        })

        this.condition = conditionsss;
        if(needInitForm){
            this.form = new WeaForm();
        }
        this.form.initFormFields(conditionsss);
    }
    setCusReportAddModalShow(bool,reportid){
        this.reportid = reportid;
        
        if(bool == false){
            this.clearStatus();
        }else{
            reportid&&this.initDatas(reportid);
            reportid&&API_CUSTOMREPORTADD.getReportInfo({reportid:reportid,is_multilang_set : 1}).then((data = {})=>{
                
                const {baseInfo = {},fields = [],tableOptions = [],formulaInfo = [],groupInfo = [],sortInfo = [],sortfields=[],browserFieldProps = {}} = data;
                const {formReplaceDatas = [],reportname,wfReplaceDatas = [],formid = -1,isbill = -1} = baseInfo;

                this.browserFieldProps  = browserFieldProps;
                this.title = getLabel(386305,"编辑分析报表")+'：'+formatMultiLang(reportname);

                this.editPortFlag = true;
           
                let arr = wfReplaceDatas?wfReplaceDatas[0].id==""?[]:wfReplaceDatas:[];
                this.wfReplaceDatas = arr;

                this.reportBaseinfo =  {...this.reportBaseinfo,...{reportName:reportname,reportList:formReplaceDatas,reportRoute:arr}};
                
                this.formReplaceDatas = formReplaceDatas;
                this.wfBrowserShow = true;
                this.baseBrowserViewAttr = 1;

                this.formBrowserId = formid;
                this.formBrowserIsbill = isbill;

                this.groupData = fields.filter((field)=> {return field.groupby});;
                this.groupOptions = tableOptions;
                //group
                this.groupSelectedKeys = groupInfo;

                sortfields.map(v=>{
                    v['sortNumber'] = "1";
                });
                let sortKeys = [];

                this.tempSortInfo = sortInfo;
                //
                let formulaTempData = [];
                formulaInfo && formulaInfo.map((v,i)=>{
                    formulaTempData.push({
                        id:v.id,
                        key : v.id,
                        title:formatMultiLang(v.projectname),
                        name:<a>{v.projectname}</a>,
                        lanName:<a>{formatMultiLang(v.projectname)}</a>,
                        formula:<a>{v.formula}</a>,
                        formulaDesc:<a>{formatMultiLang(v.formulaDesc)}</a>
                    })
                })
                this.proJectDataSource = formulaTempData;
                //
                this.baseInfoFlag = 1;
                this.groupFlag = 1;
                this.sortFlag = 1;
                this.proJectFlag = 1;
                this.setNowFormInfo(true,formReplaceDatas,[],reportname,{wf:{formid:formid,isbill:isbill},form:{workflowid:wfReplaceDatas.length>0?wfReplaceDatas[0].id:''}},[3,2,1]);
               
            });
            if(!reportid) {//新建
                API_CUSTOMREPORTADD.getBrowserInfo().then(data => {
                    this.baseInfoItemList = data.itemList;
                    this.initForms();
                });
            }
        }
        this.customReportAddModalShow = bool;
    }
    initForms(){
        this.setNowFormInfo(true);
    }
    setProJectAddModalShow(bool){
        this.lockState = 1;
        this.proJectAddModalShow = bool;
        if(!bool){
            this.formulaName = "";
            this.proJectModalParams = {};
            this.proJectTitle = getLabel(386303,"新建统计项目");
            this.formulaForm = new WeaForm();
            this.formulaForm.initFormFields(this.formulaCondition);
        }
    }
    //
    clearStatus(){
        this.reportid = "";
        this.title = getLabel(386304,"新建分析报表");
        this.editPortFlag = false;

        this.reportBaseinfo={
            reportName:"",
            reportList:[],
            reportRoute:[],
            workflowToFormid:'',
            workflowToIsbill:''
        }
        this.firstChoose = 1;

        this.wfReplaceDatas = [];
        this.formReplaceDatas=[];
        this.formBrowserId = '';
        this.formBrowserIsbill = '';
        this.wfBrowserShow = false;
        this.baseBrowserViewAttr = 3;

        this.groupData = [];
        this.sortData = [];
        this.sortSelectedDatas = [];

        this.groupSelectedKeys = [];
        this.sortSelectedKeys = [];
        this.proJectDataSource=[];
        this.proJectRowKeys  = [];
        this.deleteKeys =[];

        this.currentStep = 0;
        this.baseInfoFlag = 0;
        this.groupFlag = 0;
        this.sortFlag = 0;
        this.proJectFlag = 0;

        this.resetForm();
    }
    //
    
    setCurrentStep(index){
        this.currentStep = index;
    }
    // 

    setBaseInfo(params={}){
        this.reportBaseinfo = {...this.reportBaseinfo,...params};
        this.baseInfoFlag = 0;
        if(params.reportRoute&&params.reportRoute.length<=0){//清空路径时
            // this.form = new WeaForm();
            // this.form.initFormFields(this.condition);
            // setTimeout(() => {
            //     this.appendFormFields({reportname:{value:this.reportBaseinfo.reportName}})
            // }, 10);
        }
    }
    baseInfoFormChange(id,names,datas){
        this.appendFormFields({form:{value:id,valueSpan:names,valueObj:[{id:id,name:names}]}});//手动赋值，解决验证首次不通过
        this.formReplaceDatas=datas;
        if(id){
            this.reportBaseinfo = {...this.reportBaseinfo,reportList:datas,reportRoute:[],workflowToFormid:''};
            this.firstChoose = 2;
        }else{
            this.reportBaseinfo = {...this.reportBaseinfo,reportList:datas};
            this.firstChoose = 1;
        }
        
        this.formBrowserId = id;
        this.formBrowserIsbill = datas.length>0?datas[0].isbill:'';
    }
    workflowPathOnchange(params=[],params2={},datas=[]){
        let arr = [],workflowToFormid='',workflowToIsbill='';
        if(params.length>0&&params[0].id){
            params[0].id = ""+params[0].id;
            this.formBrowserId = params[0].id;
            this.formBrowserIsbill = params[0].isbill;
            // this.firstChoose = 1;
            workflowToFormid = params[0].id;
            workflowToIsbill = params[0].isbill;
            this.appendFormFields({form:{value:params[0].id,valueSpan:params[0].name,valueObj:[{id:params[0].id,name:params[0].name}]}});//手动赋值，解决验证首次不通过
        }
        this.reportBaseinfo = {...this.reportBaseinfo,reportList:params,reportRoute:datas,workflowToFormid,workflowToIsbill};
        this.baseInfoFlag = 0;

        // this.form = new WeaForm();
        // this.form.initFormFields(this.condition);
        setTimeout(() => {
            this.appendFormFields({reportname:{value:this.reportBaseinfo.reportName}})
        }, 10);
       
    }
    //
    setGroupDatas(keys){
        this.groupSelectedKeys = keys;
        this.groupFlag = 0;
    }
    //
    setSortDatas(keys,datas){
        this.sortSelectedDatas = datas;
        this.sortSelectedKeys = keys;
        this.sortFlag = 0;
    }
    setSortSelectedDatasOrder(item,v){
        let arr1 = this.sortSelectedDatas;
        let arr2 = this.sortData.slice();
        arr1.map((c,i)=>{
            if(item.id==c.id){
                arr1[i].sortNumber = v;
            }
        });
        arr2.map((c,i)=>{
            if(item.id==c.id){
                arr2[i].sortNumber = v;
            }
        });
        this.sortSelectedDatas = arr1;
        this.sortData = arr2;
        this.sortFlag = 0;
    }
    //统计项目
    setFormulaName(v){
        this.formulaName = v;
    }
    
    //
    setDataSource(datas,deleteKeys){
        this.proJectDataSource = datas;
        if(deleteKeys){
            this.deleteKeys = deleteKeys
            this.proJectRowKeys = [];
        }
        this.proJectFlag = 0;
    }
    setProJectRowKeys(keys){
        this.proJectRowKeys = keys;
    }
    saveFormula(formulaDesc,formula){
        if(this.proJectDataSource.length>0){
            let key = this.proJectDataSource[0].key;
            let formulaData = {};
            let flag = false;
            for(let i = 0,length=this.proJectDataSource.length;i<length;i++){
                let item = this.proJectDataSource[i];
                if(this.proJectModalParams.formulaKey==item.key){
                    item.formula = <a>{formula}</a>;
                    item.formulaDesc = <a>{formulaDesc}</a>;
                    item.name = <a>{this.formulaName}</a>;
                    item.lanName = <a>{formatMultiLang(this.formulaName)}</a>;
                    flag = true;
                    break;
                }else{
                    key = item.key>key?item.key:key;
                }
            }
            if(!flag){
                formulaData = {
                    key: key+1,
                    title: this.formulaName,
                    name: <a>{this.formulaName}</a>,
                    lanName:<a>{formatMultiLang(this.formulaName)}</a>,
                    formula: <a>{formula}</a>,
                    formulaDesc: <a>{formulaDesc}</a>
                }
                this.proJectDataSource.push(formulaData);
            }
        }else{
            this.proJectDataSource.push({
                key:0,
                title: this.formulaName,
                name: <a>{this.formulaName}</a>,
                lanName:<a>{formatMultiLang(this.formulaName)}</a>,
                formula: <a>{formula}</a>,
                formulaDesc: <a>{formulaDesc}</a>
            });
        }
        this.lockState = 1;
        this.formulaName = "";
        this.proJectFlag = 0;
        this.proJectModalParams = {};
        message.success(getLabel(83551,'保存成功！'));
        this.proJectAddModalShow = false;
    }
    proJectRowClick(datas){
        this.proJectModalParams = datas;
        this.proJectTitle = getLabel(386306,"编辑统计项目");
        this.proJectAddModalShow = true;
        this.formulaName = datas.formulaName;
        this.formulaForm.updateFields({formulaName:{value:datas.formulaName}}, false)
    };
    // ---------
    
    //保存公式拖拽后的顺序
    saveformulaListIndex(datas) {
        this.proJectDataSource =  datas;
        this.proJectFlag = 0;
    }

}